<template>
	<view class="">
		<u-navbar @rightClick="rightClick" :placeholder="true" :fixed="true" bgColor="#ffffff" :autoBack="true">
			<template v-slot:left>
				<view class="xflex-x">
					<image class="logo" :src="logoimg" mode=""></image>
					<view class="logoText">
						{{logoname}}
					</view>
					<view class="xfz24 xc90 xml32">
						{{logoTps}}
					</view>
				</view>
			</template>
			<template v-slot:center>
				<view></view>
			</template>
		</u-navbar>
		<view class="search">
			<search :keyword='types.keyword' @search="submit" @scan="scans()" :left-show="searchdata == 1" />
		</view>

		<view class="xflex-x-between xpl24 xpr24">
			
		</view>



		<view class="title xp20-25" id="title">
			<!-- <view class="xmb24">
				<selecte label="类型" keys="cc" ref="cc" @ondblclick="db" v-model:value="types.typename" placeholder="请选择类型" :showData="types.typename.name"
					:list="condition.typename" stateType="2" keyName="name" lName="child" tName="name" />
			</view> -->
			<view class="xmb24" v-if="brandShow == 1">
				<selecte label="品牌" keys="cc" ref="cc" @ondblclick="db" v-model:value="types.branname"
					placeholder="请选择品牌" :showData="types.branname.name" :list="condition.branname" stateType="2"
					keyName="name" lName="child" tName="name" />
			</view>
			<view class="xmb24" v-if="ztShow == 1">
				<selecte label="直通" keys="cc" ref="cc" @ondblclick="db" v-model:value="types.typename"
					placeholder="请打开直通、专项抵达" :showData="types.typename.name" :list="condition.typename" stateType="2"
					keyName="name" lName="child" tName="name" />
			</view>
			<view class="xmb24" v-if="hdShow == 1">
				<selecte label="厚度" keys="cc" ref="cc" @ondblclick="db" v-model:value="types.brand" placeholder="请选择厚度"
					:showData="types.brand.name" :list="condition.brand" stateType="2" keyName="name" lName="child"
					tName="name" />
			</view>
			<view class="xmb24" v-if="geShow == 1">
				<selecte @ondblclick="db" keys="ge" label="规格" ref="ge" v-model:value="types.spec" placeholder="请选择规格尺寸"
					:showData="types.spec.name" :list="condition.spec" keyName="name" lName="child" tName="name"
					clabel="更多:" />
			</view>

			<view class="xmb24" v-if="gyShow == 1">
				<selects label="工艺" keys="gy" ref="gy" @ondblclick="db" v-model:value="types.technology"
					placeholder="请选择工艺种类" :showData="types.technology.name" :list="condition.technology" keyName="name"
					lName="child" tName="name" clabel="更多:" />
			</view>
			<view class="xmb24" v-if="cpShow == 1">
				<selects label="产品" keys="cp" ref="cp" @ondblclick="db" v-model:value="types.classification"
					placeholder="请选择产品类别" :showData="types.classification.name" :list="condition.classification"
					keyName="name" lName="child" tName="name" clabel="更多:" />
			</view>
			
			
			<view class="xmb24" v-if="taShow == 1">
				<selecte label="区类" keys="ta" ref="ta" @ondblclick="db" v-model:value="types.typea"
					placeholder="请选择产品区类" :showData="types.typea.name" :list="condition.typea" stateType="2"
					keyName="name" lName="child" tName="name" />
				
			</view>
			
			<view class="xmb24" v-if="tbShow == 1">
				<selecte label="颜色" keys="tb" ref="tb" @ondblclick="db" v-model:value="types.typeb"
					placeholder="请选择颜色" :showData="types.typeb.name" :list="condition.typeb" stateType="2"
					keyName="name" lName="child" tName="name" />
				
			</view>
			
			<view v-if="calcShow == 1" class="xfz24 xfw500 xc9">搜索结果：{{goodsList.count}}个效果图</view>
		</view>

		<view class=" xp20-25 xmt50" @click.stop="toTop()" v-if="show" style="position: fixed;top: 104rpx;">
			<view class="xmb24" @click.stop="toTop()">
				<selects label="返回顶部" v-model:value="pageTitle" :delimg="false" :showData="filtername" :list="[]"
					keyName="name" lName="list" tName="name" @ondblclick="toTop" />
			</view>

		</view>

		<view class="goods xp20-25 xflex-x-between">
			<view class="goodsItem" v-for="(item,index) in goodsList.list" :key="index">
				<image lazy-load="true" @click="toPages('/pages/index/detail/detail?id='+item.id)" :key="index"
					class="img" :src="item.image" mode="" style=""></image>

				<view class="xp24 xbs" style="width: 100%;">
					<view class="xflex-x-between">
						<view class="xfz28 xc3 xflex1 clamp" v-if="ppShow == 1" @click="submit(item.brand_name)" style="text-align: left;">
							{{item.brand_name}}
						</view>
						<view class="xfz26 xc90 xflex1 clamp" v-if='nameShow == 1' @click="submit(item.name)"
							style="text-align: right;width: 20rpx;">

							{{item.name}}
						</view>

					</view>
					
					
					<view class="xflex-x-between">
						
						<view class="xfz24 xc90 xmt20 clamp" v-if="bmShow == 1" @click="submit(item.alias_name)" style="text-align: left;">
							{{item.alias_name}}
						</view>
						<view class="xfz24 xc90 xmt20 xflex1 clamp" v-if='kcShow == 1' @click="submit(item.stock)"
							style="text-align: right;">
					
							{{item.stock}}
						</view>
					
					</view>
				
				</view>
				
			</view>
		</view>

		<u-popup :show="popupshow" mode="center" :round="10">
			<view class="popup">
				<view class="popup-title">
					温馨提示
				</view>
				<view class="popup-content">
					会员登录，享受更优服务哦~
					你还未登录会员
				</view>
				<view class="popup-btn" @click="login()">
					去登录
				</view>
			</view>
		</u-popup>

		<u-popup :show="isplayshow" mode="center" :round="10">
			<view class="popup">
				<view class="popup-title">
					温馨提示
				</view>
				<view class="popup-content">
					你还未开通使用功能
				</view>
				<view class="popup-btn" @click="gm()">
					去开通
				</view>
			</view>
		</u-popup>

		<u-popup :show="wxplayshow" mode="center" :round="10">
			<view class="popup pr">
				<view class="popup-gb pa">
					<u-icon name="close" @click="wxplayshow = false" color="#666" size="24"></u-icon>
				</view>
				<view class="popup-title">
					温馨提示
				</view>
				<view class="popup-content">
					你还未开通使用功能
				</view>
				<view class="popup-btn" @click="getPlay()">
					去开通
				</view>
			</view>
		</u-popup>


		<u-popup :show="searchshow" mode="center" :round="10">
			<view class="popup pr">
				<view class="popup-gb pa">
					<u-icon name="close" @click="gb()" color="#666" size="24"></u-icon>
				</view>
				<view class="popup-title">
					温馨提示
				</view>
				<view class="popup-content">
					以图搜图为百度提供的付费项目，你要充值进行付费吗？
				</view>
				<view class="popup-btn" @click="toPage('/pages/mine/recharge')">
					去充值
				</view>
			</view>
		</u-popup>


		<u-popup :show="infoshow" mode="center" :round="10">
			<view class="popup pr" >
				<view class="popup-gb pa">
					<u-icon name="close" @click="infoshow = false" color="#666" size="24"></u-icon>
				</view>
				<view class="popup-title">
					{{infoTitle}}
				</view>
				<video v-if="infotypeShow == 1" :src="infourl" controls id="myvideo" style="width: 100%;margin-top: 50rpx;" @fullscreenchange="screenChange"></video>
				<scroll-view scroll-y="true" style="height: 680rpx;"  v-else>
					<view class="" style="padding: 60rpx;" >
						
						<u-parse :content="infotext"></u-parse>
					</view>
				</scroll-view>
			</view>
		</u-popup>
	</view>
</template>
<script> 
export default {
	
	// 分享到微信好友功能
	onShareAppMessage(res) {
		console.log(res,"onShareAppMessage");
		return {
			title: '岩搜搜',
			path: '/pages/index/index' + "?data=" + JSON.stringify(uni.getStorageSync('types')) + '&utype=' + uni.getStorageSync("identity_id") + '&mobile=' + uni.getStorageSync("mobile")  +
				'&pid=' + uni.getStorageSync("user")?.userinfo?.id ,
			desc: this.share.desc || '',
			imageUrl: this.share.imageUrl,
			success(res) {
				uni.showToast({
					title: '分享成功'
				})
				
				console.log(this.share.path,"分享瑞金");
			},
			fail(res) {
				uni.showToast({
					title: '分享失败',
					icon: 'none'
				})
				console.log(this.share.path,"分享失败");
			}
		}
	},
	// 分享到朋友圈功能
	onShareTimeline(res) {
		return {
			title: this.share.title,
			path: '/pages/index/index' + "?data=" + JSON.stringify(uni.getStorageSync('types')) + '&utype=' + uni.getStorageSync("identity_id") +
				'&pid=' + uni.getStorageSync("user")?.userinfo?.id  + '&mobile=' + uni.getStorageSync("mobile"),
			desc: this.share.desc || '',
			imageUrl: this.share.imageUrl,
			success(res) {
				uni.showToast({
					title: '分享成功'
				})
				console.log(this.share.path,"分享瑞金");
			},
			fail(res) {
				uni.showToast({
					title: '分享失败',
					icon: 'none'
				})
				console.log(this.share.path,"分享失败");
			}
		}
	},

}
</script>
<script setup>
	import {
		onReachBottom,
		onShow,
		onLoad,
		onPageScroll
	} from '@dcloudio/uni-app';
	import {
		reactive,
		ref,
		watchEffect,
		getCurrentInstance,
		watch,
		computed
	} from 'vue';

	import selects from './components/selects.vue';
	import selecte from './components/select.vue';
	import search from './components/search.vue';

	import {
		spec,
		classification,
		technology,
		brand,
		getGoods,
		uploadFile,
		thickness,
		site,
		searchnum,
		goodstype,
		userpop,
		userinfos,
		usercharge,
		userlogout,
		accesslists,
		indexconfig,
		accesstypea,
		accesstypeb
	} from "@/network/home.js"
	import {
		useCounterStore
	} from '@/Store/index'
	const counter = useCounterStore()
	import {
		receipt,

	} from "@/hooks/utils.js"

	let times = ref('');
	let show = ref(false)
	onPageScroll((e) => {
		const time = Date.now();
		if (time - times.value > 100) {
			times.value = time;
			const instance = getCurrentInstance(); // 获取组件实例
			const DOMArr = uni.createSelectorQuery().in(instance);
			DOMArr.select('.title')
				.boundingClientRect(poster => {
					console.log(poster.bottom);
					if (poster.bottom < 0) {
						show.value = true
					} else {
						show.value = false
					}
				})
				.exec();
		}
	});
	
	
	const videoShow = (item) => {
		
		 // this这个是实例对象 必传
		
	}
	
	const screenChange = (e) => {
		let fullScreen = e.detail.fullScreen; // 值true为进入全屏，false为退出全屏
		let videoContext = uni.createVideoContext("myvideo", this);
		if(!fullScreen){
			videoContext.stop()
		}else {
			videoContext.requestFullScreen({
				direction: 90
			});
			videoContext.play();
		}
		
	
	}
	
	



	const exit = () => {
		userlogout({
			client: 2
		})
		uni.clearStorage()

		uni.reLaunch({
			url: "/pages/index/login"
		})
	}
	
	
	


	const toPages = (url) => {
		if (isOpenPage.value == 0) {
			uni.showToast({
				icon: "none",
				title: "权限不足"
			})
			return
		}
		
		if(isVipshow.value){
			wxplayshow.value = true
			
			
			return
		}
		
		
		uni.setStorageSync('types', types)

		uni.navigateTo({
			url: url
		})
	}




	let popupshow = ref(false)

	let selle = reactive({
		top: 0,
		brand_sort: 0,
		spec_sort: 0,
		thickness_sort: 0,
		price_sort: 0
	})




	// 点击条件
	const tj = (index, type) => {
		selle.top = index
		if (index == 0) {
			submit()
			return
		}
		if (selle[type] == 2) {
			selle[type] = 0
		} else {
			selle[type] = selle[type] + 1
		}
		submit()
	}

	let pageTitle = ref('');

	let filtername = ref('')

	// 获取规格条件
	let condition = reactive({
		spec: [],
		brand: [],
		technology: [],
		classification: [],
		typename: [],
		typea:[],
		typeb:[]
	})

	goodstype().then(res => {
		console.log(res);
		condition.typename = res.data
	})

	const getCondition = async () => {
		let specData = await spec()
		
		
		let brandData = await thickness()
		let technologyData = await technology()
		let classificationData = await classification()
		let branname = await brand()
		
		let typealist = await accesstypea()
		let typeblist = await accesstypeb()
		condition.branname = branname.data
		condition.spec = specData.data
		condition.brand = brandData.data
		condition.technology = technologyData.data
		condition.classification = classificationData.data
		condition.typea = typealist.data
		condition.typeb = typeblist.data
	}
	let types = reactive({
		spec: {
			id: '',
			name: ''
		},
		brand: {
			id: '',
			name: ''
		},
		technology: {
			id: '',
			name: ''
		},
		classification: {
			id: '',
			name: ''
		},
		typename: {
			id: '',
			name: ''
		},
		branname: {
			id: '',
			name: ''
		},
		typea:{
			id:'',
			name:''
		},
		typeb:{
			id:'',
			name:''
		},
		keyword: ''
	})

	uni.$on('update', function(data) {
		console.log("=======", data, "事件");
		types.spec = data.spec
		types.brand = data.brand
		types.technology = data.technology
		types.classification = data.classification
		types.typename = data.typename
		types.branname = data.branname
		types.keyword = data.keyword
		types.typea = data.typea
		types.typeb = data.typeb
		setTimeout(() => {
			sub()
		}, 500)
	})

	// 获取商品列表
	let goodsList = reactive({
		list: [],
		page: 1,
		pageSize: 10,
		count: 0,
		keyword: '',
		show: false,

	})

	const gb = () => {
		searchshow.value = false
	}



	const brandclick = (data) => {
		console.log(data, condition.brand);
		condition.brand.forEach(item => {
			if (data.brand_id == item.id) {
				types.brand = item
				return
			}

		})
	}


	const toTop = () => {
		setTimeout(() => {
			show.value = false
			uni.pageScrollTo({
				scrollTop: 0,
				duration: 30
			});
		}, 50);
	}

	const login = () => {

		uni.reLaunch({
			url: '/pages/index/login'
		})
	}

	// let infoshow = ref(false)
	// let infotext = ref('')
	// let infoTitle = ref('')
	const getuserpop = () => {
		userpop().then(res => {
			console.log("=res", res);
			if (res.data.status == 1) {
				infotext.value = res.data.content
				infoTitle.value = res.data.title
				infoshow.value = true
			}
		})
	}

	const scans = async () => {
		
		
		if (searchPopShow.value == 1) {
			searchshow.value = true
			return
		}

		// if (isScan.value) {
		// 	uni.showToast({
		// 		icon: "none",
		// 		title: "请注册登录"
		// 	})
		// 	return
		// }


		// console.log("====");
		uni.chooseImage({
			count: 1,
			sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
			success: chooseImageRes => {
				const tempFilePaths = chooseImageRes.tempFilePaths;
				console.log(chooseImageRes);
				uploadFile(tempFilePaths[0]).then(res => {
					setTimeout(() => {
						uni.navigateTo({
							url: "/pages/index/search?urls=" + res.data.fullurl
						})
					}, 500)
				}).catch(Error => {
					console.log(Error, "错误");
					uni.showToast({
						icon: "error",
						title: "图片上传失败"
					})

				})
			}
		})

	}

	let ge = ref()
	let cc = ref()
	let gy = ref()
	let cp = ref()
	let ta = ref()
	let tb = ref()
	const db = (e) => {
		if (e == 'ge') {
			// ge.value.onshow()
			cp.value.onshow()
			cc.value.onshow()
			gy.value.onshow()
		}
		if (e == 'cc') {
			ge.value.onshow()
			// cp.value.onshow()
			// cc.value.onshow()
			gy.value.onshow()
		}
		if (e == 'gy') {
			ge.value.onshow()
			cp.value.onshow()
			cc.value.onshow()
			// gy.value.onshow()
		}
		if (e == 'cp') {
			ge.value.onshow()
			// cp.value.onshow()
			cc.value.onshow()
			gy.value.onshow()
		}
		if (e == 'ta') {
			tb.value.onshow()
			ge.value.onshow()
			cp.value.onshow()
			cc.value.onshow()
			gy.value.onshow()
		}
		if(e == 'tb'){
			//
			ta.value.onshow()
			ge.value.onshow()
			cp.value.onshow()
			cc.value.onshow()
			gy.value.onshow()
		}
		console.log(e);
	}
	watch(
		types,
		(newVal, oldVal) => {
			uni.setStorageSync('types', newVal)
			console.log(newVal,"===222=====");
			
			filtername.value = ''
			filtername.value = types.spec?.name + types.brand.name + types.technology.name + types
				.classification
				.name + types.branname.name
			sub()
			uni.$mpShare = shareData.value
		}, {
			deep: true
		}
	)

	const submit = (e) => {
		types.keyword = e
		console.log(goodsList, "========1");
		// uni.$mpShare = shareData.value
		sub()

	}

	const sub = () => {

		console.log(goodsList);
		goodsList.page = 1
		goodsList.show = false
		goodsList.list = []
		getGoodsList()
	}

	const toPage = (url) => {
		uni.navigateTo({
			url: url
		})
	}

	const getGoodsList = async () => {
		let data = {
			page_no: goodsList.page,
			page_size: "10",
			spec_id: types.spec.id || '',
			brand_id: types.branname.id || '',
			thickness: types.brand.name || '',
			technology_id: '',
			classification_id: '',
			keyword: types.keyword || '',
			type_id: types.typename.id || '',
			brand_sort: selle.brand_sort,
			spec_sort: selle.spec_sort,
			thickness_sort: selle.thickness_sort,
			price_sort: selle.price_sort,
			typea_id:types.typea.id,
			typeb_id:types.typeb.id,
		}
		console.log(data, "======");

		if (types.spec) {
			let arr = []
			// if (types.spec.child && types.spec.child.length != 0) {
			// 	types.spec.child.forEach(item => {
			// 		arr.push(item.id)
			// 	})
			// 	console.log(types.spec);
			// 	data.spec_ids = arr.toString()
			// } else {
			data.spec_id = types.spec.id || ''
			// }
		}
		if (types.technology) {
			let arr = []
			if (types.technology.child && types.technology.child.length != 0) {
				types.technology.child.forEach(item => {
					arr.push(item.id)
				})
				data.technology_id = arr.toString()
			} else {
				data.technology_id = types.technology.id || ''
			}
		}
		if (types.classification) {
			let arr = []
			if (types.classification.child && types.classification.child.length != 0) {
				types.classification.child.forEach(item => {
					arr.push(item.id)
				})
				data.classification_id = arr.toString()
			} else {
				data.classification_id = types.classification.id || ''
			}
		}

		uni.$u.throttle(async () => {
			let res = await getGoods(data)
			console.log(res);
			goodsList.list.push(...res.data.lists)
			goodsList.count = res.data.count
			goodsList.page++
			if (res.data.lists.length < 10) {
				goodsList.show = true
			}
		}, 200, false)


	}


	const getPlay = () => {

		uni.navigateTo({
			url: "/pages/mine/vip/vips"
		})
		return
		// usercharge().then(res => {
		// 	uni.requestPayment({
		// 		provider: 'wxpay',
		// 		timeStamp: res.data.timeStamp,
		// 		nonceStr: res.data.nonceStr,
		// 		package: res.data.package,
		// 		signType: res.data.signType,
		// 		paySign: res.data.paySign,
		// 		success: function(res) {
		// 			console.log('success:' + JSON.stringify(res));
		// 			uni.showToast({
		// 				title: '支付成功',
		// 				icon: 'none'
		// 			});
		// 			wxplayshow.value = false
		// 		},
		// 		fail: function(err) {
		// 			console.log('fail:' + JSON.stringify(err));
		// 			uni.showToast({
		// 				title: '支付失败',
		// 				icon: 'none'
		// 			});
		// 		}
		// 	});
		// })
	}

	
	// 支付弹窗
	const getuserinfo = () => {
		userinfos().then(res => {
			console.log("“sio", res.data);

		})
	}


	let isOpenPage = ref(0)
	let isScan = ref(false)
	let isbrand = ref(false)
	let isplayshow = ref(false)
	let brandShow = ref(0)
	let ztShow = ref(0)
	let hdShow = ref(0)
	let geShow = ref(0)
	let gyShow = ref(0)
	let cpShow = ref(0)
	
	let ppShow = ref(0)
	
	
	let calcShow = ref(0)
	let nameShow = ref(0)
	let bmShow = ref(0)
	let kcShow = ref(0)
	
	let taShow = ref(0)
	let tbShow = ref(0)
	
	
	
	const getsite = () => {
		site().then(res => {
			console.log(res.data.is_open_reg == 1, "====");
			brandShow.value = res.data.brand
			ztShow.value = res.data.zt
			calcShow.value = res.data.calc
			nameShow.value = res.data.index_name
			if (res.data.goods_detail == 0) {
				isOpenPage.value = true
			}
			if (res.data.search_img == 0) {
				isScan.value = true
			}
			if (res.data.brand_status == 1) {
				isbrand.value = true
			}

			if (res.data.is_pay == 1) {
				isplayshow.value = true
			}

			if (res.data.identity_id == 2 && res.data.charge == 1) {
				wxplayshow.value = true
			}

			if (res.data.is_open_reg == 1) {
				uni.getStorage({
					key: "token",
					success: (res) => {
						console.log(res.errMsg == 'getStorage:ok' && res.data == '',
							"=======");
						if (res.errMsg == 'getStorage:ok' && res.data != '') {} else {
							popupshow.value = true
						}
						console.log(res);
					},
					fail: (err) => {
						popupshow.value = true
					}
				})
			}
		})
	}

	const gm = () => {
		uni.navigateTo({
			url: "/pages/mine/vip/vip"
		})
	}

	let searchshow = ref(false)
	let searchdata = ref(0)
	let logoimg = ref('')
	let logoname = ref('')
	let logoTps = ref('')
	let searchPopShow = ref(0)
	
	
	let infoshow = ref(false)
	let infotext = ref('')
	let infoTitle = ref('')
	
	let infotypeShow = ref(0)
	let infourl = ref('')
	
	let wxplayshow = ref(false)
	
	let isVipshow = ref(false)
	
	
	indexconfig().then(res=>{
		
		
		logoimg.value = res.data.image
		logoname.value = res.data.name
		logoTps.value = res.data.label
		searchPopShow.value = res.data.search_pop
		
		infoshow.value = res.data.pop.status == 1
		infotext.value = res.data.pop.content
		infoTitle.value = res.data.pop.title
		infotypeShow.value = res.data.pop.type
		infourl.value = res.data.pop.file
		
		
		if(res.data.charge.status == 1){
			infoshow.value = false
			isVipshow.value = true
			
		}
		
		
		
	})
	const getaccesslists  = () =>{
		accesslists().then(res=>{
			console.log(res);
			
			if (res.data.account_login == 1) {
				uni.getStorage({
					key: "token",
					success: (res) => {
						if (res.errMsg == 'getStorage:ok' && res.data != '') {} else {
							popupshow.value = true
						}
					},
					fail: (err) => {
						popupshow.value = true
					}
				})
			}
			
			
			// 以图搜图是否可用
			searchdata.value = res.data.index_search_image
			// 品牌是否显示
			brandShow.value = res.data.index_brand_filter
			// 直通是否显示
			ztShow.value = res.data.index_type_filter
			
			hdShow.value = res.data.index_thickness_filter
			geShow.value = res.data.index_spec_filter
			gyShow.value = res.data.index_technology_filter
			
			cpShow.value = res.data.index_classification_filter
			
			calcShow.value = res.data.index_statistics
			
			
			ppShow.value = res.data.index_brand_name
			nameShow.value = res.data.index_goodsname
			bmShow.value = res.data.index_alias
			kcShow.value = res.data.index_stock
			isOpenPage.value = res.data.goodsinfo_detail
			
			taShow.value = res.data.index_typea_filter
			tbShow.value = res.data.index_typeb_filter
			
			
			
			
			
			
			
		})
	}
	
	
	// 获取次数
	// const getsearchnum = () => {
	// 	searchnum().then(res => {

	// 		searchdata.value = res.data.status
	// 	})
	// }

	onReachBottom(() => {
		if (goodsList.show) return
		getGoodsList()

	})

	onShow(() => {
		// getuserinfo()
		// uni.setStorage({
		// 	key:"types",
		// 	success(data) {
		// 		console.log("数据",data);
		// 		if(data){
		// 			 Object.assign(types, result)
		// 		}
				
		// 	}
		// })
		uni.$on('update', function(data) {
			console.log('首页监听到事件来自 update ，携带参数 msg 为：' + data.msg);
		})
		// getsearchnum()
		getaccesslists()
		
		// getsite()
	})
	const shareData = computed(() => { // 分享的数据
		try {
			console.log(JSON.stringify(types));
			return {
				title: '',
				desc: '',
				path: 'pages/index/index?data=' + JSON.stringify(types) + '&utype=' + uni
					.getStorageSync(
						"identity_id") + '&pid=' + uni.getStorageSync("user").userinfo.id +
					'&mobile=' + uni
					.getStorageSync("mobile"),
				imageUrl: '',
			}
		} catch (e) {
			// error
		}

	})
	onLoad((option) => {
		getCondition()
		// getuserpop()
		setTimeout(() => {
			uni.$mpShare = shareData.value
		}, 1000)
		console.log("===optione", option);
		if (counter.info) {
			types.spec = JSON.parse(counter.info).spec
			types.brand = JSON.parse(counter.info).brand
			types.technology = JSON.parse(counter.info).technology
			types.classification = JSON.parse(counter.info).classification
			types.typename = JSON.parse(counter.info).typename
			types.branname = JSON.parse(counter.info).branname
			types.keyword = JSON.parse(counter.info).keyword
			types.typea = JSON.parse(counter.info).typea
			types.typeb = JSON.parse(counter.info).typeb
		}

		if (option.data) {
			types.spec = JSON.parse(option.data).spec
			types.brand = JSON.parse(option.data).brand
			types.technology = JSON.parse(option.data).technology
			types.classification = JSON.parse(option.data).classification
			types.typename = JSON.parse(option.data).typename
			types.branname = JSON.parse(option.data).branname
			types.keyword = JSON.parse(option.data).keyword
			types.typea = JSON.parse(counter.info).typea
			types.typeb = JSON.parse(counter.info).typeb
		}
		// if (option.data) {

		// }

		sub()

	})


	watchEffect(() => {
		console.log(pageTitle.value);
	});
</script>

<style lang="scss" scoped>
	.search {
		padding: 28rpx 32rpx 40rpx;
	}

	.img {
		width: 335rpx;
		height: 586rpx;
		background-color: #eee;

	}

	.goods {}

	.logo {
		width: 46rpx;
		height: 46rpx;
		margin-right: 3rpx;
	}

	.logoText {
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #333333;
		line-height: 48rpx;
	}

	.goodsItem {
		background-color: #fff;
		text-align: center;
		margin-bottom: 20rpx;
		padding: 10rpx 0;


	}

	.popup {
		width: 600rpx;
		// height: 400rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		padding-bottom: 20rpx;

		&-gb {
			right: 32rpx;
			top: 20rpx;
		}

		&-title {
			font-size: 36rpx;
			font-weight: bold;
			color: #333333;
			margin-top: 50rpx;
			text-align: center;
		}

		&-content {
			width: 349rpx;
			height: 57rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
			line-height: 31rpx;
			margin: auto;
			margin-top: 50rpx;
			text-align: center;
		}

		&-btn {
			width: 220rpx;
			height: 80rpx;
			background: #3F7233;
			border-radius: 10rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
			line-height: 80rpx;
			text-shadow: 0rpx 2rpx 10rpx rgba(0, 0, 0, 0.2);
			text-align: center;
			margin: auto;
			margin-top: 95rpx;
		}
	}

	.sort {
		width: 24rpx;
		height: 24rpx;
	}

	.selle {
		color: #ff5500;
	}
</style>